package com.Lixiaoqian.CardPlay.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.Lixiaoqian.CardPlay.R;
import com.Lixiaoqian.CardPlay.base.BaseActivity;
import com.Lixiaoqian.CardPlay.common.customview.RoundAngleImageView;

import butterknife.BindView;
import com.Lixiaoqian.CardPlay.utils.CameraCutUtils;
import com.Lixiaoqian.CardPlay.utils.Constant;
import com.Lixiaoqian.CardPlay.utils.ToastUtils;

import static com.Lixiaoqian.CardPlay.utils.Constant.CHOOSE_PICTURE;
import static com.Lixiaoqian.CardPlay.utils.Constant.CROP_SMALL_PICTURE;
import static com.Lixiaoqian.CardPlay.utils.Constant.TAKE_PICTURE;

public class PersonActivity extends BaseActivity implements View.OnClickListener{

    @BindView(R.id.et_person_name)
    EditText etPersonName;
    @BindView(R.id.et_person_email)
    EditText etPersonEmail;
    @BindView(R.id.btn_person_save)
    Button btn_save;
    @BindView(R.id.radio_man)
    RadioButton radioMan;
    @BindView(R.id.radio_men)
    RadioButton radioMen;
    @BindView(R.id.radioGroup)
    RadioGroup radioGroup;
    @BindView(R.id.user_image)
    RoundAngleImageView userImage;

    private int user_id;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initData();
        initEvent();

    }

    private void initEvent() {
        btn_save.setOnClickListener(this);

        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                ToastUtils.showShort(PersonActivity.this,checkedId+"");
            }
        });
    }


    private void initData() {
    }

    @Override
    public int getLayoutID() {
        return R.layout.activity_person;
    }

    public static void launch(Activity fromActivity) {
        fromActivity.startActivityForResult(new Intent(fromActivity, PersonActivity.class),1000);
    }

    public void userImageClick(View view){
        CameraCutUtils.showChoosePicDialog(this);
    }
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        //super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case TAKE_PICTURE:
                CameraCutUtils.startPhotoZoom(Constant.uritempFile,this); // 开始对图片进行裁剪处理
                break;
            case CHOOSE_PICTURE:
                if (data != null)
                    CameraCutUtils.startPhotoZoom(data.getData(),this); // 开始对图片进行裁剪处理
                break;
            case CROP_SMALL_PICTURE:
                CameraCutUtils.setImageToView(this,userImage);
                break;
        }
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_person_save:
                setResult(1001);
                finish();
                break;
        }
    }
}
